//
//  FaceResultModel.swift
//  MM2
//
//  Created by 李成明 on 2022/1/3.
//

import CoreGraphics

class FaceResultModel: BaseModel {
    var image_id: String?
    var request_id: String?
    var time_used: Int = 0
    var face_num: Int = 0
    
    var faces: [FaceModel] = []
}

class FaceAnalyzeModel: BaseModel {
    var time_used: Int = 0
    var request_id: String?
    var faces: [FaceModel] = []
}

class FaceModel: BaseModel {
    var face_token: String?
    var face_rectangle: FaceRectangleModel?
    var attributes: FaceAttributesModel?
}

class FaceRectangleModel: BaseModel {
    var width: Int = 0
    var top: Int = 0
    var left: Int = 0
    var height: Int = 0
}


class FaceAttributesModel: BaseModel {
    var gender: FaceValueModel?
    var age: FaceIntValue?
    var glass: FaceValueModel?
    var headpose: FaceHeadposeModel?
    var smile: FaceSmileModel?
    var blur: FaceBlurModel?
    var emotion: FaceEmotionModel?
    var beauty: FaceBeautyModel?
    var skinstatus: FaceSkinstatusModel?
    var facequality: FacequalityModel?
}

class FaceValueModel: BaseModel {
    var value: String = ""
}
class FaceIntValue: BaseModel {
    var value: Int = 0
}

class FaceHeadposeModel: BaseModel {
    var yaw_angle: Float = 0
    var pitch_angle: Float = 0
    var roll_angle: Float = 0
}

class FaceSmileModel: BaseModel {
    var threshold: Float = 0
    var value: Float = 0
}

class FaceBlurModel: BaseModel {
    var motionblur: FaceValueModel?
    var gaussianblur: FaceValueModel?
    var blurness: FaceValueModel?
}

class FaceEmotionModel: BaseModel {
    var anger: Float = 0
    var disgust: Float = 0
    var fear: Float = 0
    var happiness: Float = 0
    var neutral: Float = 0
    var sadness: Float = 0
    var surprise: Float = 0
    
    var emotionType: EmotionType {
        var maxValue = anger
        var emotionType: EmotionType = .anger(value: anger)
        if disgust > maxValue {
            emotionType = .disgust(value: disgust)
            maxValue = disgust
        }
        
        if fear > maxValue {
            emotionType = .fear(value: fear)
            maxValue = fear
        }
        
        if happiness > maxValue {
            emotionType = .happiness(value: happiness)
            maxValue = happiness
        }
        
        if neutral > maxValue {
            emotionType = .neutral(value: neutral)
            maxValue = neutral
        }
        
        if sadness > maxValue {
            emotionType = .sadness(value: sadness)
            maxValue = sadness
        }
        
        if surprise > maxValue {
            emotionType = .surprise(value: surprise)
            maxValue = surprise
        }
        return emotionType
    }
}

class FacequalityModel: BaseModel {
    var value: Float = 0
    var threshold: Float = 0
}

class FaceBeautyModel: BaseModel {
    var male_score: Float = -1
    var female_score: Float = -1
}

class FaceSkinstatusModel: BaseModel {
    var health: Float = 0
    var stain: Float = 0
    var acne: Float = 0
    var dark_circle: Float = 0
}
class FaceLandmarkModel: BaseModel {
    
}
